@import '../../style/index.scss';

$radio: 'uni-radio';

.#{$radio} {
  font-size: $font-size-normal;
  font-variant: tabular-nums;
  line-height: $line-height-normal;
  color: rgba(0, 0, 0, 0.65);
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  list-style: none;
  cursor: pointer;
  display: inline-block;

  &:hover {
    .#{$radio}-select-inner {
      border-color: $color-brand-normal;
    }
  }

  &-select {
    font-size: $font-size-normal;
    font-variant: tabular-nums;
    color: rgba(0, 0, 0, 0.65);
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    list-style: none;
    white-space: nowrap;
    cursor: pointer;
    outline: none;
    display: inline-block;
    line-height: 1;
    position: relative;
    vertical-align: middle;
    top: -0.09em;

    input {
      position: absolute;
      left: 0;
      z-index: 1;
      cursor: pointer;
      opacity: 0;
      top: 0;
      bottom: 0;
      right: 0;
      width: 100%;
      height: 100%;
    }

    &-inner {
      position: relative;
      top: 0;
      left: 0;
      display: block;
      width: 16px;
      height: 16px;
      border: 1px solid #d9d9d9;
      border-radius: 100px;
      background-color: #fff;
      -webkit-transition: all 0.3s;
      transition: all 0.3s;
      border-collapse: separate;

      &::after {
        position: absolute;
        width: 8px;
        height: 8px;
        left: 3px;
        top: 3px;
        border-radius: 8px;
        display: table;
        border-top: 0;
        border-left: 0;
        content: ' ';
        background-color: $color-brand-normal;
        opacity: 0;
        -webkit-transform: scale(0);
        -ms-transform: scale(0);
        transform: scale(0);
        -webkit-transition: 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
        transition: 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
      }
    }
  }

  &-label {
    padding: 0 8px;
  }

  &-checked {
    .#{$radio}-select-inner {
      border-color: $color-brand-normal;

      &::after {
        -webkit-transform: scale(0.875);
        -ms-transform: scale(0.875);
        transform: scale(0.875);
        opacity: 1;
        -webkit-transition: all 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
        transition: all 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
      }
    }

    .#{$radio}-select {
      &::after {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 2px;
        border: 1px solid $color-brand-normal;
        content: '';
        -webkit-animation: antCheckboxEffect 0.36s ease-in-out;
        animation: antCheckboxEffect 0.36s ease-in-out;
        -webkit-animation-fill-mode: both;
        animation-fill-mode: both;
        visibility: hidden;
      }
    }
  }

  &-disabled {
    cursor: not-allowed;

    .#{$radio}-select {
      cursor: not-allowed;
    }

    .#{$radio}-select-inner {
      border-color: #d9d9d9 !important;
      background-color: #f5f5f5;

      &::after {
        background-color: rgba(0, 0, 0, 0.2);
      }
    }
  }

  input[type='radio'][disabled] {
    cursor: not-allowed;
  }
}
